import globals from "globals"
import pluginJs from "@eslint/js" // 推荐 检验js规范
import tseslint from "typescript-eslint" // 推荐 检验ts规范
import pluginVue from "eslint-plugin-vue" // 推荐 检验vue规范
import prettierRecommend from "eslint-config-prettier"

import { createRequire } from "module"
const require = createRequire(import.meta.url)
const autoImportConfig = require("./.eslintrc-auto-import.json")

export default [
  { files: ["**/*.{js,mjs,cjs,ts,vue}"] },
  {
    languageOptions: {
      globals: {
        ...globals.browser,
        ...globals.node,
        ...autoImportConfig.globals
      }
    }
  },
  pluginJs.configs.recommended,
  ...tseslint.configs.recommended,
  ...pluginVue.configs["flat/essential"],
  // 校验vue中ts代码
  {
    files: ["**/*.vue"],
    languageOptions: { parserOptions: { parser: tseslint.parser } }
  },
  {
    // 哪些不需要通过 eslint 校验的文件
    ignores: ["*.css", "*.d.ts"],
    rules: {
      "no-console": "warn",
      semi: ["error"],
      "vue/multi-word-component-names": "off"
    }
  },
  prettierRecommend // prettier 覆盖掉 eslint
]
